package purse;

import account.Account;

/**
 * 通宝账户类
 * 
 * @author 毛建杰
 *
 */
public class Purse
{
	private Account account;
	private int gold;
	private GoldProvider goldProvider;

	/**
	 * 构造方法
	 * 
	 * @param account
	 *            账号
	 * @param purseProvider
	 *            通宝操作接口
	 */
	public Purse(Account account, GoldProvider goldProvider)
	{
		this.account = account;
		this.goldProvider = goldProvider;
		this.gold = this.goldProvider.query(this.account);
	}

	/**
	 * 充值通宝
	 * 
	 * @param gold
	 *            充值数量
	 * @return 通宝余额
	 */
	public int addGold(int gold)
	{
		goldProvider.add(account, gold);
		this.gold = goldProvider.query(account);
		return this.gold;
	}

	/**
	 * 获取账号
	 * 
	 * @return 账号
	 */
	public Account getAccount()
	{
		return account;
	}

	/**
	 * 获取通宝余额
	 * 
	 * @return 通宝余额
	 */
	public int getGold()
	{
		return gold;
	}

}
